<template>
  <div class="IPBOX">
    <input
      class="ip"
      type="text"
      v-model="IP"
      placeholder="请输入接口IP地址"
      disabled
    />
    <div style="width:50%" class="btnBox">
      <button class="btn" @click="setIP" v-items>确定</button>
      <button class="btn" @click="deleteto" v-items>退格</button>
    </div>

    <div class="box">
      <span
        @click="setIPText('http://')"
        v-items="{ default: true }"
        style="width:100%;"
        >http://</span
      >
      <span
        v-items
        v-for="(item, index) in 10"
        :key="index"
        @click="setIPText(index)"
      >
        {{ index }}
      </span>
      <span @click="setIPText('.')" v-items>.</span>
      <span @click="setIPText(':')" v-items>:</span>
      <span @click="setIPText('http://47.103.128.167:9191')" v-items
        >http://47.103.128.167:9191</span
      >
      <span @click="setIPText('http://172.17.121.22:9191')" v-items
        >http://172.17.121.22:9191</span
      >
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      IP: ''
    };
  },
  created() {},
  methods: {
    setIP() {
      this.$store.commit('setIP', this.IP);
      if (this.$store.getters.getIP) {
        this.$router.push({
          path: '/home'
        });
      }
    },
    setIPText(index) {
      this.IP = this.IP + index;
    },
    deleteto() {
      this.IP = this.IP.substring(0, this.IP.length - 1);
    }
  }
};
</script>

<style lang="less" scoped>
.IPBOX {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
.ip {
  width: 80%;
  height: 100px;
}
.btnBox {
  display: flex;
  flex-direction: row;
}
.btn {
  width: 50%;
  height: 50px;
  margin: 10px;
  background: #aaa;
}
.box {
  width: 80%;
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}
.box > span {
  background: #aaa;
  margin: 10px;
}
.box > span:action {
  background: #000;
}
span {
  padding: 4px;
  display: block;
  width: 28%;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>
